﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
namespace MINERP.DAL.InfoConfig
{
    public class ProductCategoryDAL:DALBase
    {
        private static ObjectQuery<Tb_PorductCategory> GetProductCategorys()
        {
            return DataEntites.Tb_PorductCategory;
        }


        /// <summary>
        /// Get PorductCategory list
        /// </summary>
        /// <returns></returns>
        public static List<Tb_PorductCategory> GetProductCategoryList()
        {
            List<Tb_PorductCategory> list = new List<Tb_PorductCategory>();
            foreach (Tb_PorductCategory porductCategory in GetProductCategorys())
            {
                list.Add(porductCategory);
            }
            return list;
        }
        /// <summary>
        /// Get PorductCategory object
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Tb_PorductCategory GetProductCategoryObj(string name)
        {
            return DataEntites.Tb_PorductCategory.First(p => p.ProductCategoryName == name);
        }

        /// <summary>
        /// Get PorductCategory object
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Tb_PorductCategory GetProductCategoryObj(int id)
        {
            return DataEntites.Tb_PorductCategory.First(p => p.ProductCategoryId ==id);
        }

        public static void Add(Tb_PorductCategory obj)
        {
            DataEntites.AddToTb_PorductCategory(obj);
            DataEntites.SaveChanges();
        }
        public static void Update()
        {
            DataEntites.SaveChanges();
        }

        public static void Delete(Tb_PorductCategory obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
